Hello forum users,
I'm just a beginner learning all these things about pointers, dynamic memory etc..
The point is: I'm writing some code to get pratice with the language. I'm now learning about Dynamic memory (actually I'm learning about everything, that's all new stuff to me)
Ok, guilty, I talk too much. I'll show you my piece of code:
Code:
int* bfThis(int *nArray, int nSize)
{
int *newArray = new int[nSize];
nArray += nSize - 1;
for (int nCounter = nSize - 1, i = 0; nCounter >= 0; nCounter--, nArray--, i++) *(newArray+i) = *nArray;
return newArray;
}
int main()
{
int nTest[] = {11,10,9,8,7,6,5,4,3,2,1,0};
int* hehe = bfThis(nTest, 12);
for (int i = 0; i < 12; i++) cout << hehe[i];
cout << endl;
delete[] hehe;
for (int i = 0; i < 12; i++) cout << hehe[i];
cout << endl;
system("pause");
return 0;
}
Please, what I want to know is: am I doing right the new&delete thing? I tought that setting free the memory space and initializing some strings the '0 1 2 3 4...' should disappear...
So, please, can someone tell me what I'm doing so wrong?
Thank you very much for the attention, readers. And sorry for my bad english, I'm a foreign speaker...
Arthur